package com.deng.eventflow.core.tmf;

import com.deng.eventflow.core.SynchronousProcessor;

import java.util.Queue;

public class Filter extends SynchronousProcessor {
    public Filter() {
        super(2, 1);
    }

    @Override
    protected boolean compute(Object[] inputs, Queue<Object[]> outputs) {
        Object o = inputs[0];
        Object[] out = new Object[1];
        boolean b = (Boolean) inputs[inputs.length - 1];
        if (b)
        {
            out[0] = o;
        }
        else
        {
            return true;
        }
        outputs.add(out);
        return true;
    }

    @Override
    public Filter duplicate(boolean with_state) {
        return new Filter();
    }
}
